package com.dingding.credential;

import java.util.UUID;

import org.apache.log4j.Logger;

import com.dingding.bean.databean.request.ReqCheckUpdate;
import com.dingding.bean.databean.response.ResCheckUpdate;
import com.dingding.cache.cacheutil.DataUtil;
import com.dingding.common.core.util.MD5Util;
import com.dingding.common.core.util.ToolUtil;

/**
 * 
 * @ClassName: GeneraterClinetSequence 
 * @Description: 生成手机唯一标识
 * @author cheshaowei
 * @date 2015-12-3 上午10:34:20
 */
public class GeneraterClinetSequence {

	private static final Logger log = Logger.getLogger(GeneraterClinetSequence.class);

	/**
	 * @Title: generaterAppId 
	 * @Description:生成手机唯一标识
	 * @author cheshaowei
	 * @throws
	 */
	public static boolean generaterAppId(ReqCheckUpdate reqCheckUpdate, ResCheckUpdate resCheckUpdate) {

		// 没有请求数据
		if (reqCheckUpdate == null || ToolUtil.isBlank(reqCheckUpdate.getImei())) {

			log.error("检查更新: imei为空");
			return false;

		}

		String appId = UUID.randomUUID().toString();
		String app_token = MD5Util.md5Encrypt(reqCheckUpdate.getImei());

		DataUtil dataUtil = new DataUtil();
		// 缓存数据库 2:用于存储手机标识
		// String responseCode = dataUtil.setValue(appId, app_token, 2);

		// if (responseCode != null && responseCode.equals("OK")) {

		// 添加缓存成功
		resCheckUpdate.setAppId(app_token);
		return true;

		// } else {
		//
		// log.error("添加手机标识到缓存数据库失败！IMEI号：" + reqCheckUpdate.getImei());
		// // 添加缓存失败
		// return false;
		// }

	}

}
